<?php 
namespace Member\Controller;

class ManageController extends MemberController {
	function _initialize() {
		parent::_initialize();
		$info  = $this->oFind('WechatApp', I('get.appid'));
		$Quota = M('WechatQuota')->where('appid='.$info['id'])->find();
		$info['connect'] = $Quota['connect'];
		$info['request'] = $Quota['request'];
		$info['attention'] = $Quota['attention'];
		$info['document']  = $Quota['document'];
		$this->assign('appInfo' ,$info);
	}
	
	function index($appid) {
		if (IS_POST) {
			$model = D('WechatApp');
			$data['id'] = I('post.id');
			$data['appid'] = I('post.appid');
			$data['appsecret'] = I('post.appsecret');
			$data['update_time'] = NOW_TIME;
			if ($model->save($data)) {
				$this->success('保存成功！');
			}else {
				$this->error('保存失败！');
			}
		}else {
			$this->title('基础设置');
			$this->display();
		}
	}
	/**
	 * 服务号认证
	 */
	function approve() {
		
	}
	
	function pay($type, $appid) {
		switch ($type) {
			case 'connect' : $title = '响应次数充值'; break;
			case 'request' : $title = '请求次数充值'; break;
			case 'document' : $title = '文档数量充值'; break;
			case 'attention' : $title = '响应次数充值'; break;
			default: $this->error('参数错误！');
		}
		$this->title($title);
		$this->display();
	}
}